Mention the name of a package in a custom build failure
authorAlex Crichton <alex@alexcrichton.com>
Sun, 7 Sep 2014 23:01:55 +0000 (16:01 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Sun, 7 Sep 2014 23:06:19 +0000 (16:06 -0700)
Closes #530

src/cargo/ops/cargo_rustc/mod.rs
tests/test_cargo_compile.rs

index f9cb09631554ef291ec30159b0c17bc0ade51877..e56ae4b31e85d976a93bb567414b99f30e6bc936 100644 (file)
@@ -182,6 +182,7 @@ fn compile_custom(pkg: &Package, cmd: &str,
         p = p.env(format!("DEP_{}_OUT_DIR", name).as_slice(),
                   Some(&layout.native(pkg)));
     }
+    let pkg = pkg.to_string();
 
     Ok(proc() {
         if first {
@@ -193,7 +194,11 @@ fn compile_custom(pkg: &Package, cmd: &str,
                 internal("failed to create output directory for build command")
             }));
         }
-        try!(p.exec_with_output().map(|_| ()).map_err(|e| e.mark_human()));
+        try!(p.exec_with_output().map(|_| ()).map_err(|mut e| {
+            e.msg = format!("Failed to run custom build command for `{}`\n{}",
+                            pkg, e.msg);
+            e.mark_human()
+        }));
         Ok(())
     })
 }
index 9c754cc347e9365f0fd4bc50a0640f33b06aa68b..2e16fca231f3a2aaf70af1e86c6245101e58c3c0 100644 (file)
@@ -691,11 +691,13 @@ test!(custom_build_failure {
         "#);
     assert_that(p.cargo_process("build"),
                 execs().with_status(101).with_stderr(format!("\
+Failed to run custom build command for `foo v0.5.0 ({dir})
 Process didn't exit successfully: `{}` (status=101)\n\
 --- stderr\n\
 task '<main>' failed at 'nope', {filename}:2\n\
 \n\
-", build.bin("foo").display(), filename = format!("src{}foo.rs", path::SEP))));
+", build.bin("foo").display(), filename = format!("src{}foo.rs", path::SEP),
+   dir = p.url())));
 })
 
 test!(custom_second_build_failure {
@@ -752,11 +754,13 @@ test!(custom_second_build_failure {
         "#);
     assert_that(p.cargo_process("build"),
                 execs().with_status(101).with_stderr(format!("\
+Failed to run custom build command for `foo v0.5.0 ({dir})
 Process didn't exit successfully: `{}` (status=101)\n\
 --- stderr\n\
 task '<main>' failed at 'nope', {filename}:2\n\
 \n\
-", build2.bin("bar").display(), filename = format!("src{}bar.rs", path::SEP))));
+", build2.bin("bar").display(), filename = format!("src{}bar.rs", path::SEP),
+   dir = p.url())));
 })
 
 test!(custom_build_env_vars {